<?php

namespace App\Jobs;

use App\Services\OrderService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class SecKillOrderJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    private $user;
    private $sku_id;
    private $activity_id;

    /**
     * Create a new job instance.
     *
     * @param OrderService $order
     * @param $user
     * @param $sku_id
     * @param $activity_id
     * @throws \App\Exceptions\InvalidRequestException
     */
    public function __construct($user, $sku_id, $activity_id)
    {

        $this->user = $user;
        $this->sku_id = $sku_id;
        $this->activity_id = $activity_id;
    }

    /**
     * Execute the job.
     *
     * @param OrderService $order
     * @return void
     * @throws \App\Exceptions\InvalidRequestException
     */
    public function handle(OrderService $order)
    {
       $order->preOrder($this->user, $this->sku_id, $this->activity_id);
    }
}
